package com.yupi.yupicturebackend.service;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.IService;
import com.yupi.yupicturebackend.model.dto.user.UserEditRequest;
import com.yupi.yupicturebackend.model.dto.user.UserQueryRequest;
import com.yupi.yupicturebackend.model.vo.CaptchaVO;
import com.yupi.yupicturebackend.model.vo.UserVO;
import com.yupi.yupicturebackend.model.entity.User;
import com.yupi.yupicturebackend.model.vo.LoginUserVO;

import javax.servlet.http.HttpServletRequest;
import java.util.List;

/**
 * 用户 服务层。
 *
 * @author <a href="https://github.com/liyupi">程序员鱼皮</a>
 */
public interface UserService extends IService<User> {

    /**
     * 用户注册
     *
     * @param userAccount   用户账户
     * @param userPassword  用户密码
     * @param checkPassword 校验密码
     * @return 新用户 id
     */
//    long userRegister(String userAccount, String userPassword, String checkPassword);

    /**
     * 加密
     *
     * @param userPassword 用户密码
     * @return 加密后的密码
     */
    String getEncryptPassword(String userPassword);
    /**
     * 获取脱敏的已登录用户信息
     *
     * @return
     */
    /**
    LoginUserVO userLogin(String userAccount, String userPassword, HttpServletRequest request);


     * 获取当前登录用户
     *
     * @param request
     * @return
     */
    User getLoginUser(HttpServletRequest request);


    /**
     * 获取脱敏的登录用户信息
     *
     * @return
     */
    LoginUserVO getLoginUserVO(User user);
    /**
     * 用户注销
     *
     * @param request
     * @return
     */
    boolean userLogout(HttpServletRequest request);

    public UserVO getUserVO(User user);

    public List<UserVO> getUserVOList(List<User> userList);

    public QueryWrapper getQueryWrapper(UserQueryRequest userQueryRequest);
    /**
     * 是否为管理员
     *
     * @param user
     * @return
     */
    boolean isAdmin(User user);

    boolean exchangeVip(User user,String vipCode);

    /**
     * 根据用户邮箱查询用户是否存在
     *
     * @param userEmail 用户邮箱
     * @return true/false
     */
    boolean queryUserByEmail(String userEmail);
    /**
     * 根据用户邮箱查询用户
     *
     * @param userEmail 用户邮箱
     * @return 用户信息
     */
    User getUserByUserEmail(String userEmail);

    /**
     * 发送邮箱验证码
     *
     * @param userEmail 用户邮箱
     * @return 验证码
     */
    String sendEmailCode(String userEmail);

    /**
     * 用户注册
     *
     * @param userEmail 用户邮箱
     * @param codeKey   验证码key
     * @param codeValue 验证码值
     * @return 新用户 id
     */
    long userRegister(String userEmail,String codeKey,String codeValue,String userPassword);

    CaptchaVO getCaptcha();

    LoginUserVO userLogin(String userAccount, String userPassword, String captchaKey, String captchaCode, HttpServletRequest request);

    void editUser(UserEditRequest userEditRequest);
}
